package com.haoshuang.zhouzhoubang.ui.page.welfare

import com.haoshuang.zhouzhoubang.model.api.ApiRepo
import com.haoshuang.zhouzhoubang.model.bean.PlatformWelfareBean
import com.mufeng.libs.base.BaseViewModel
import com.mufeng.libs.net.netRequest
import com.mufeng.libs.state.StateData
import com.mufeng.libs.state.StatefulMutableLiveData

class PlatformWelfareHomeViewModel : BaseViewModel() {


    /**
     * 获取平台福利列表
     */
    val getWelfareListData = StatefulMutableLiveData<MutableList<PlatformWelfareBean>>()
    fun getWelfareList() = netRequest {
        start { getWelfareListData.value = StateData.Loading }
        request { ApiRepo.getWelfareList()  }
        success { getWelfareListData.value = StateData.Success(it.data) }
        error { code, msg ->
            getWelfareListData.value = StateData.Error(code, msg)
        }
    }

}